<?php

/*
| +----------------------------------------------------------------------
| | DyCode 框架[为Dy自主开发框架]
| +----------------------------------------------------------------------
| | Copyright (c) 2015-2030 https://www.ngiveup.top/
| +----------------------------------------------------------------------
| | DyCode 提供个人非商业用途免费使用，商业需授权。
| +----------------------------------------------------------------------
| | Author: dy <wdyxzkq@qq.com>
| +----------------------------------------------------------------------
|
*/

declare (strict_types = 1);

if (!function_exists('sendOutput')) {
    /**
     * 统一的接口输入格式
     * @param string $data 数据
     * @param int $errorcode 错误编码
     * @param string $msg 消息提醒
     */
    function sendOutput($data = [], $code = 0, $msg = '')
    {
        $sendMessage = [
            'code'    => $code,
            'msg'     => $msg ?: (!$code ? 'ok' : 'error'),
            'data'    => $data,
            'version' => 'v1.0.0',
        ];

        header('content-type:application/json');

        exit(json_encode($sendMessage, JSON_UNESCAPED_UNICODE));
    }
}
